#include <stdio.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/rpc.h>
#include <unistd.h>




#define PROGNUM 0x20000100
#define VERSNUM 1
#define PROCNUM 1

int * proc_dist(int *n) 
{ 
	static int res = 0;
	int i=0;
	printf("entered\n");
	while(i<10)
	{
  		printf("distante %d\n",*n);
  		sleep(1);
  		i++;
  	}
	printf("exited\n");
  	return &res;
}


int main (void) 
{
	int i=0;
	
	printf("register\n");
	
  	registerrpc(/* prognum */ PROGNUM,
	     /* versnum */ VERSNUM,
	     /* procnum */ PROCNUM,
	     /* pointer on function */ proc_dist,
	     /* argument decoding */ (xdrproc_t)xdr_int,
	     /* function result encoding */ (xdrproc_t)xdr_int);

	printf("registered\n");
	
  	svc_run(); /* server ready for clients */
  
	printf("ready\n");
	
	while(i<10)
	{
  		printf("serveur\n");
  		sleep(1);
  		i++;
  	}
  	
  	return 0;
}


